Skip to content

[Unify CustomOp Headerfile] Inference headerfile includes paddle/extension.h #51745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jiahy0825
Copy link
Contributor

@jiahy0825 jiahy0825 commented Mar 16, 2023

PR types

Function optimization

PR changes

Others

Describe

Pcard-66988

随着 phi 的规范化程度不断提高,一些具有“experimental”的标识可以考虑移除。
用户在使用自定义算子做推理时,需要替换引入的头文件,本 PR 在保证兼容性的前提下,将 paddle/extension.h 头文件也拷贝到推理目录下,使得用户在推理场景下使用自定义算子时,不需要做源码改动。

As the standardization of phi continues to increase, some flags with "experimental" may be considered for removal.
Users must substitute the header file to include/experimental/ext_all.h when using the custom operators in the inference scenario. Under the premise of ensuring compatibility, this PR copies the paddle/extension.h header file into the inference directory so that users do not need to change the source file when they use custom operators under inference scenario.

@jiahy0825 jiahy0825 force-pushed the unify-inference-customOP-headerfile branch from 99fc873 to a3ce6e9 Compare March 16, 2023 12:08
@qingqing01 qingqing01 requested a review from jiweibo March 21, 2023 02:18
@@ -51,3 +51,6 @@ phi_header_path_compat(
file(RENAME
${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/extension.h
${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/ext_all.h)
# Included header file of training and inference can be unified as single file: paddle/extension.h
file(COPY ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/ext_all.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ext_all.h的内容:

 15 #pragma once
 16
 17 // All paddle apis in C++ frontend
 18 #include "paddle/include/experimental/phi/api/all.h"
 19 // Python bindings for the C++ frontend
 20 #ifndef PADDLE_ON_INFERENCE
 21 #include "paddle/include/experimental/utils/pybind.h"
 22 #endif

这里的相对路径关系不影响吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的路径关系是正确的,不会影响,并且需要引用的也是 ext_all.h 中的相对路径~

原来用户需要引用的头文件是 paddle/include/experimental/ext_all.h,现在把这个文件拷贝到 ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/extension.h,相当于用户引用的头文件变成了 paddle/extension.h,从而达成自定义算子下,训练和推理引用头文件一致的效果。用户不需要做源码改动,提高易用性。

@jiweibo jiweibo requested a review from yuanlehome March 21, 2023 02:31
@@ -51,3 +51,6 @@ phi_header_path_compat(
file(RENAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前experimental下的不需要删除吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

出于兼容性的考虑,之前 experimental 下的应该删不掉~

@jiahy0825 jiahy0825 merged commit 1816ceb into PaddlePaddle:develop Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants